//
//  DelegatesController.m
//  BSProject
//
//  Created by nsm on 2019/7/11.
//  Copyright © 2019 beisheng. All rights reserved.
//

#import "DelegatesController.h"

@interface TestDelegator : NSObject <UITextFieldDelegate>

@end

@implementation TestDelegator
- (void)hehe {
    
}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
    NSLog(@"[%@]%s", self,__func__);
}
@end

@interface DelegatesController ()
@property (nonatomic, strong) TestDelegator *delegator1;
@property (nonatomic, strong) TestDelegator *delegator2;
@property (nonatomic, strong) UITextField *textField;
@end

@implementation DelegatesController

#pragma mark - lifeCycle

#pragma mark - override

#pragma mark - initialization
- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITextField *textField = UITextField.new;
    textField.backgroundColor = UIColor.yellowColor;
    textField.size = CGSizeMake(200, 40);
    textField.center = CGSizeCenter(kScreenSize);
    textField.top = 44;
    textField.textColor = COLOR_0;
    textField.placeholder = @"看LOG输出";
    [self.view addSubview:textField];
    _textField = textField;
    
    _delegator1 = TestDelegator.new;
    _delegator2 = TestDelegator.new;
    
    self.textField.delegatesEnabled = YES;
    textField.delegate = _delegator1;
    textField.delegate = _delegator2;
    
    [textField removeDelegate:_delegator2];
    
    id obj = self.textField.delegate;
    
    BOOL ok = [self.textField.delegate respondsToSelector:@selector(hehe)];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        BOOL ojbk = [self.textField respondsToSelector:@selector(nsm_setDelegate:)];
        NSLog(@"ojbk:%@", @(ojbk));
    });
}

#pragma mark - setter/getter

#pragma mark - network

#pragma mark - method/public

#pragma mark - method/private

#pragma mark - action

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
